package com.quanyan.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Client
 *
 * @author Tu Chun
 * @date 2017/1/3
 */
public class Client {
    public static void main(String[] args) {
        Subject realSubject=new RealSubject();
        InvocationHandler handler = new DynamicProxy(realSubject);
        Subject subjectProxy = (Subject) Proxy.newProxyInstance(realSubject.getClass().getClassLoader(), realSubject.getClass().getInterfaces(), handler);
        System.out.println(subjectProxy.getClass().getName());
        subjectProxy.rent();
        subjectProxy.hello("world");
    }
}
